home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************/
- /* WriteFromTE */
- /* */
- /* Writes to open file from existing TextEdit record */
- /************************************************************************************/
-
- #include "MyHeaders.h"
-
- long WriteFromTE(short pathRefNum, TEHandle hTE)
- {
- OSErr writeErr; /* return from I/O routines */
- long bytesWrite = 0; /* total of bytes returned */
- Ptr beginP; /* ptr to begin of temp I/O area */
-
- CursorSelect (NIL, NIL, watchCursor); /* set watch cursor */
-
- writeErr = SetFPos (pathRefNum, fsFromStart, 0); /* positn file ptr to begin */
-
- bytesWrite = (**hTE).teLength; /* number of bytes to write */
- beginP = *(**hTE).hText; /* pointer to text */
-
- writeErr = FSWrite (pathRefNum, &bytesWrite, beginP); /* write to the file */
- if (writeErr == noErr)
- SetEOF (pathRefNum, bytesWrite); /* set new EOF */
- else
- {
- ParamText (workReply.fName,NIL,NIL,NIL); /* set text as file name */
- PlaceAlert (140); /* position the alert */
- StopAlert (140, NIL); /* show the alert */
- }
-
- return bytesWrite; /* return total no of bytes */
- }
-